home *** CD-ROM | disk | FTP | other *** search
Text File | 1998-10-30 | 4.5 KB | 200 lines | [TEXT/CWIE] |
- { Add.p -- Modal dialog }
- { Created 10/30/98 1:03 PM by AppMaker }
-
- Unit Add;
- Interface
-
- Uses
- Types,
- Quickdraw,
- Controls,
- Dialogs,
- Events,
- Lists,
- Menus,
- TextEdit,
- DReminder,
- AMDialog;
-
- type
- CAdd = object (AMDialog)
-
- {data members}
- mData: DReminder;
-
- mOKHandle: ControlHandle;
- mCancelHandle: ControlHandle;
- mDate2Handle: ControlHandle;
- mTime2Handle: ControlHandle;
- mMessage2Handle: ControlHandle;
- mDisplayIconHandle: ControlHandle;
- mDisplayAlertHandle: ControlHandle;
- mPlaySoundHandle: ControlHandle;
- mSoundPopupHandle: ControlHandle;
-
- {methods - public}
- Procedure ConnectToData (inData: AMSignaler); Override;
-
- {methods - internal}
- Procedure FinishMake; Override;
- Procedure DoItem (inItemHit: SInt16); Override;
- Procedure DataChanged (inDataID: longint); Override;
-
- end;
-
- {----------}
- Function NewAdd: CAdd;
-
- {----------}
- Function GetAdd (ioData: DReminder): Boolean;
-
- {----------}
- Implementation
-
- Uses
- ResourceDefs,
- ControlUtils,
- Miscellany;
-
- const
- kOKButton = 1;
- kCancelButton = 2;
- kLogoPicture = 3;
- kAddReminderForLabel = 4;
- kDateLabel = 5;
- kDate2Field = 6;
- kTimeLabel = 7;
- kTime2Field = 8;
- kMessageLabel = 9;
- kMessage2Field = 10;
- kWhenRemindingLabel = 11;
- kDisplayIconCheck = 12;
- kDisplayAlertCheck = 13;
- kPlaySoundCheck = 14;
- kSoundPopupPopup = 15;
-
-
- {----------}
- Function NewAdd: CAdd;
- var
- dialog: CAdd;
- begin
- dialog := nil;
- New (dialog);
-
- if dialog <> nil then begin
- dialog.Initialize;
- end;
- NewAdd := dialog;
- end;
-
- {----------}
- Function GetAdd (
- ioData: DReminder): Boolean;
- Var
- result: Boolean;
- dialog: CAdd;
- begin
- result := false;
- dialog := NewAdd;
-
- result := dialog.RunModal (DLOG_Add, ioData);
-
- dialog.Free;
- Dispose (dialog);
-
- GetAdd := result;
- end;
-
- {----------}
- Procedure CAdd.FinishMake;
- var
- errCode: OSErr;
- begin
- mOKHandle := GetControlItem (kOKButton);
- SetDefaultState (mOKHandle, true);
- errCode := SetDialogDefaultItem (mDialog, kOKButton);
- mCancelHandle := GetControlItem (kCancelButton);
- errCode := SetDialogCancelItem (mDialog, kCancelButton);
- mDate2Handle := GetControlItem (kDate2Field);
- mTime2Handle := GetControlItem (kTime2Field);
- mMessage2Handle := GetControlItem (kMessage2Field);
- mDisplayIconHandle := GetControlItem (kDisplayIconCheck);
- mDisplayAlertHandle := GetControlItem (kDisplayAlertCheck);
- mPlaySoundHandle := GetControlItem (kPlaySoundCheck);
- mSoundPopupHandle := GetControlItem (kSoundPopupPopup);
- end;
-
- {----------}
- Procedure CAdd.ConnectToData (
- inData: AMSignaler); Override;
- begin
- inherited ConnectToData (inData);
- mData := DReminder (inData);
-
- SetClockDateTime (mDate2Handle, mData.GetDateTime);
- SetClockDateTime (mTime2Handle, mData.GetDateTime);
- SetControlText (mMessage2Handle, mData.GetMessage);
- SetControlValue (mDisplayIconHandle, ord (mData.GetShowIcon));
- SetControlValue (mDisplayAlertHandle, ord (mData.GetShowAlert));
- SetControlValue (mPlaySoundHandle, ord (mData.GetPlaySound));
- SetControlValue (mSoundPopupHandle, mData.GetSoundIndex);
- end;
-
- {----------}
- Procedure CAdd.DoItem (
- inItemHit: SInt16);
- begin
- case inItemHit of
- kOKButton:
- SetResult (true);
- kCancelButton:
- SetResult (false);
- kDate2Field:
- mData.SetDateTime (GetClockDateTime (mDate2Handle));
- kTime2Field:
- mData.SetDateTime (GetClockDateTime (mTime2Handle));
- kMessage2Field:
- mData.SetMessage (GetEditTextStr (mMessage2Handle));
- kDisplayIconCheck:
- mData.SetShowIcon (ToggleCheckbox (mDisplayIconHandle));
- kDisplayAlertCheck:
- mData.SetShowAlert (ToggleCheckbox (mDisplayAlertHandle));
- kPlaySoundCheck:
- mData.SetPlaySound (ToggleCheckbox (mPlaySoundHandle));
- kSoundPopupPopup: begin
- mData.SetSoundIndex (GetControlValue (mSoundPopupHandle));
- end;
-
- end; {switch}
- end;
-
- {----------}
- Procedure CAdd.DataChanged (
- inDataID: longint); Override;
- begin
- if inDataID = idDateTime then begin
- SetClockDateTime (mDate2Handle, mData.GetDateTime);
- end;
- if inDataID = idDateTime then begin
- SetClockDateTime (mTime2Handle, mData.GetDateTime);
- end;
- if inDataID = idMessage then begin
- SetControlText (mMessage2Handle, mData.GetMessage);
- end;
- if inDataID = idShowIcon then begin
- SetControlValue (mDisplayIconHandle, ord (mData.GetShowIcon));
- end;
- if inDataID = idShowAlert then begin
- SetControlValue (mDisplayAlertHandle, ord (mData.GetShowAlert));
- end;
- if inDataID = idPlaySound then begin
- SetControlValue (mPlaySoundHandle, ord (mData.GetPlaySound));
- end;
- if inDataID = idSoundIndex then begin
- SetControlValue (mSoundPopupHandle, mData.GetSoundIndex);
- end;
- end;
-
- End.
-